//
//  FindViewCell.m
//  TeamWork
//
//  Created by lanou3g on 15/11/17.
//  Copyright © 2015年 Project. All rights reserved.
//

#import "FindViewCell.h"

@interface FindViewCell ()

// 头像
@property (nonatomic, strong) UIImageView *imgView;

// 名字
@property (nonatomic, strong) UILabel *nameLabel;

// 距离现在多长时间发布的
@property (nonatomic, strong) UILabel *timeLabel;

// 点赞和评论按钮
@property (nonatomic, strong) UIButton *setButton;

// 发布的文字
@property (nonatomic, strong) UILabel *infoLabel;

// 发布的图片
@property (nonatomic, strong) UIImageView *photoImageView;

@end

@implementation FindViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupSubview];
    }
    return self;
}

- (void) setupSubview
{
    // 头像
    // 头像的坐标和大小
    CGFloat imgX = 10;
    CGFloat imgY = 20;
    CGFloat imgW = 50;
    CGFloat imgH = imgW;
    
    // 头像属性的设置
    self.imgView = [[UIImageView alloc] initWithFrame:CGRectMake(imgX, imgY, imgW, imgH)];
    self.imgView.backgroundColor = [UIColor redColor];
    [self addSubview:self.imgView];
    
    
    // 名字
    // 名字的坐标和大小
    CGFloat nameX = imgX * 2 + imgW;
    CGFloat nameY = imgY;
    CGFloat nameW = self.frame.size.width - nameX;
    CGFloat nameH = 30;

    
    // 名字属性的设置
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(nameX, nameY, nameW, nameH)];
    self.nameLabel.text = @"name";
    self.nameLabel.backgroundColor = [UIColor orangeColor];
    [self addSubview:self.nameLabel];
    
    
    // 发布的文字
    // 文字的坐标和大小
    CGFloat infoX = nameX;
    CGFloat infoY = nameY + nameH + 10;
    CGFloat infoW = nameW;
    CGFloat infoH = nameH * 2;

    
    // 文字属性的设置
    self.infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(infoX, infoY, infoW, infoH)];
    self.infoLabel.numberOfLines = 0;
    self.infoLabel.text = @"adsjkljfkldjfkldjf;kladjklsfj;dlskfjdls;fkjl;";
    self.infoLabel.backgroundColor = [UIColor blueColor];
    [self addSubview: self.infoLabel];
    
    
    // 发布的图片
    // 图片的坐标和大小
    CGFloat phoX = infoX;
    CGFloat phoY = infoY + infoH + 10;
    CGFloat phoW = 60;
    CGFloat phoH = 60;

    // 图片属性的设置
    self.photoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(phoX, phoY, phoW, phoH)];
    self.photoImageView.backgroundColor = [UIColor magentaColor];
    [self addSubview:self.photoImageView];
    
    
    // 时间
    // 时间的坐标和大小
    CGFloat timeX = nameX;
    CGFloat timeY = phoH + phoY + 10;
    CGFloat timeW = 60;
    CGFloat timeH = 20;

    // 时间属性的设置
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeX, timeY, timeW, timeH)];
    self.timeLabel.text = @"17hour";
    [self addSubview:self.timeLabel];
    
    
    // 按钮
    // 按钮的坐标和大小
    CGFloat btnX = 320;
    CGFloat btnY = timeY - 10;
    CGFloat btnW = 50;
    CGFloat btnH = timeH + 10;
    
    self.setButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.setButton.frame = CGRectMake(btnX, btnY, btnW, btnH);
    [self.setButton setTitle:@"Add" forState:UIControlStateNormal];
    self.setButton.backgroundColor = [UIColor redColor];
    [self addSubview:self.setButton];
}















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
